from sqlalchemy import Column, Integer, String, Float, Date, Enum
from sqlalchemy.orm import relationship
from day20.schema.schema_stu import EducationLevel
from day20.database.database import Base



class Stu(Base):
    __tablename__ = "stu"

    stu_id = Column(Integer, primary_key=True, comment="学生编号")
    class_name = Column(String(20), nullable=False, comment="学生班级")
    stu_name = Column(String(20), nullable=False, comment="学生姓名")
    native_place = Column(String(20), nullable=True, comment="籍贯")
    graduate_school = Column(String(30), nullable=True, comment="毕业院校")
    major = Column(String(20), nullable=True, comment="专业")
    enrollment_date = Column(Date, nullable=True, comment="入学时间")
    graduation_date = Column(Date, nullable=True, comment="毕业时间")
    education = Column(Enum(EducationLevel), nullable=True, comment="学历")
    advisor_id = Column(Integer, nullable=True, comment="顾问编号")
    age = Column(Integer, nullable=True, comment="年龄")
    gender = Column(String(20), nullable=True, comment="性别")

    # 添加关系定义
    stu2score = relationship("Score", back_populates="to_stu", cascade="all, delete-orphan")
    stu2emp = relationship("Emp", back_populates="to_stu", cascade="all, delete-orphan")


